package com.lgl.handle;

import com.lgl.entity.ResponseResult;
import com.lgl.enums.AppHttpCodeEnum;
import com.lgl.exception.SystemException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionHandle {
    @ExceptionHandler(SystemException.class)
    public ResponseResult sysremException(SystemException e){
        //打印异常信息
        log.error("出现了异常！ {}",e);
        return ResponseResult.errorResult(e.getCode(),e.getMsg());
    }
    @ExceptionHandler(Exception.class)
    public ResponseResult Exception(Exception e){
        //打印异常信息
        log.error("出现了异常！ {}",e);
        return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR,e.getMessage());
    }


}
